package com.ciwong.epaper.modules.epaper.util;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

/**
 * Created by keepon on 2018/10/8.
 */
public class EpaperSys {
	protected static Context mContext;

	public EpaperSys() {
	}

	public static void setContext(Context context) {
		mContext = context;
	}

	public static Context getContext() {
		return mContext;
	}
	public static float getSharedFloat(String key, float defValue) {
		return getSharedPreferences((String)null).getFloat(key, defValue);
	}
	public static SharedPreferences getSharedPreferences(String spName) {
		SharedPreferences sp;
		if (spName != null) {
			sp = mContext.getSharedPreferences(spName, 0);
		} else {
			sp = PreferenceManager.getDefaultSharedPreferences(mContext);
		}

		return sp;
	}

	public static void setSharedFloat(String key, float value) {
		SharedPreferences.Editor editor = getSharedPreferences((String)null).edit();
		editor.putFloat(key, value);
		editor.commit();
	}

}
